--[[/**
-- * 
 * 吸血效果,如果超出了生命上限, 超出部分转化为护盾
 * [0] n 万分比
 * [1] 护盾buff的id
 * @author suhaijin
-- *
-- */]]

---@class BuffEffect108100 : BaseBuffEffect
BuffEffect108100 = ClientFight.CreateClass("BuffEffect108100", ClientFight.BaseBuffEffect)
local t = BuffEffect108100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local source = buff.source;
   local parameters = {...};
    if (table.getn(parameters) < 7)then
    return IBuffEffect.FAIL;
    end
    local suckBlood =  parameters[6];
    if (suckBlood < 1)then
    return IBuffEffect.FAIL;
    end
    local beforHp = parameters[7];
    if (suckBlood < 1)then
    return IBuffEffect.FAIL;
    end
    if (source:isDie())then
    return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local overHp = beforHp + suckBlood - FighterAttributeManager.getFightAttr(source, FighterAttributeEnum.HP);
    local addHp =  (overHp * Utils.toRatio(buffEffectValue[1]));
    if (addHp < 1) then
    return IBuffEffect.FAIL;
    end
    local buffModelId = buffEffectValue[2];
    BuffManager.addBuff(fight,buff.skill,buff.source,buff.target,false,buffModelId,1,addHp,0,0,0);
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
    .. buff.modelId .. " 吸血效果 : ".. suckBlood ..",并且额外给buff施法者: " .. source.fighterId .." 转化护盾值:"..addHp);

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()